package cn.in;

import com.it.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;

@Controller
@SessionAttributes(value = "name")
public class getPOJO2 {
    /*@RequestMapping("session")
    public  String sessionModel(Model model){
        User user = new User();
        user.setName("zhang");
        user.setId(1);
        model.addAttribute("User",user);
        return "index";
    }*/


    @RequestMapping("session")
   public  String sessionModel(Model model){
       model.addAttribute("name","张仪");
        /*model.addAttribute("id","2");*/
        return "index";
    }

    @RequestMapping("session1")
    public  String sessionMode2(ModelMap modelMap){
        System.out.println(modelMap.get("name"));
        return "index";
    }

    @RequestMapping("session2")
    public String sessionModel2(SessionStatus sessionStatus){
           sessionStatus.setComplete();
           return "index";
    }
}
